/* Note: 	firm_reg_nointeract_final used for estimating firm-level FXD position by size and fxdseller 
			
*  Input: 	firm_reg_final. dta // firm_reg_v10_01_data.do

*  Tables:  Table 7, 8

*/

clear all

grstyle init
grstyle set plain, horizontal grid
grstyle set color Set1

* Set up control variables
local controls TotalAssetsLog_PRE FCLRatio_PRE Deriv_PRE  
 
********************************************************************************
*	PART I. Full sample (148 firms)
********************************************************************************
use "./Data/firm_reg_final", clear

keep if Year==2010

local i=1
* Full Sample
foreach var in "TotalNotionalNetA"  {
reg d`var' Exposed if Year==2010, vce(cluster firm)
eststo m`i'
estadd local FC "N"
local i=`i'+1

reg d`var' Exposed `controls' i.Industry1 if Year==2010, vce(cluster firm)

eststo m`i'
estadd local FC "Y"
local i=`i'+1
}
esttab m1 m2 , s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
label ///
keep(Exposed _cons)


* By Size-----------------------------------------------------------------------
* Samll Firms
local i=301
foreach var in  "TotalNotionalNetA" {
reg d`var' Exposed if Year==2010 & small_PRE==1, vce(cluster firm)
eststo m`i'
estadd local FC "N"
local i=`i'+1

reg d`var' Exposed `controls' i.Industry1 if Year==2010 & small_PRE==1, vce(cluster firm)

eststo m`i'
estadd local FC "Y"
local i=`i'+1
}
esttab m301 m302, s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
label ///
keep(Exposed _cons)


* Large Firms
local i=401
foreach var in "TotalNotionalNetA" {
reg d`var' Exposed if Year==2010 & small_PRE==0, vce(cluster firm)
eststo m`i'
estadd local FC "N"
local i=`i'+1

reg d`var' Exposed `controls' i.Industry1 if Year==2010 & small_PRE==0, vce(cluster firm)

eststo m`i'
estadd local FC "Y"
local i=`i'+1
}
esttab m401 m402, s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
label ///
keep(Exposed _cons)

///// TABLE 7 PREVIEW:
esttab  m1 m2 m301 m302 m401 m402, s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
mtitle("Full Sample" "Full Sample" "Small" "Small" "Large" "Large" ) label ///
keep(Exposed _cons) replace


* By FXD Seller----------------------------------------------------------------- 
* Exporters
local i=101
foreach var in  "TotalNotionalNetA" {
reg d`var' Exposed if Year==2010 & fxdseller_PRE==1, vce(cluster firm)
eststo m`i'
estadd local FC "N"
local i=`i'+1

reg d`var' Exposed `controls' i.Industry1 if Year==2010 & fxdseller_PRE==1, vce(cluster firm)

eststo m`i'
estadd local FC "Y"
local i=`i'+1
}
esttab m101 m102 , s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
label ///
keep(Exposed _cons)


* Importers
local i=201
foreach var in "TotalNotionalNetA" {
reg d`var' Exposed if Year==2010 & fxdseller_PRE==0, vce(cluster firm)
eststo m`i'
estadd local FC "N"
local i=`i'+1

reg d`var' Exposed `controls' i.Industry1 if Year==2010 & fxdseller_PRE==0, vce(cluster firm)

eststo m`i'
estadd local FC "Y"
local i=`i'+1
}
esttab m201 m202, s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
label ///
keep(Exposed _cons)

///// TABLE 8 PREVIEW:
esttab m101 m102 m201 m202, s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
mtitle("Exporter" "Exporter" "Non-exporter" "Non-exporter") label ///
keep(Exposed _cons) replace


 
///// EXPORT////////////////////////////////////////////////////////////////////
///// Table 7
local fn="./Output/Table_7_firm_lvl_pos_fs_size.tex"
esttab  m1 m2 m301 m302 m401 m402 using `fn', s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
mtitle("Full Sample" "Full Sample" "Small" "Small" "Large" "Large" ) label ///
keep(Exposed _cons) replace

///// Table 8
local fn="./Output/Table_8_firm_lvl_pos_fs_exporter.tex"
esttab m101 m102 m201 m202 using `fn', s(FC N r2, /// 
label("FirmControls" "N" "RSqr")) star(* 0.1 ** 0.05 *** 0.01 ) ///
mtitle("Exporter" "Exporter" "Non-exporter" "Non-exporter") label ///
keep(Exposed _cons) replace

*-------------------------------------------------------------------------------


